package gui;

import java.awt.Color;
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.SwingConstants;

public class AttackThread implements Runnable {

	GuiObject obj;
	int damage;
	MainPanel panel;
	public AttackThread(GuiObject obj,int damage, MainPanel panel){
		this.obj = obj;
		this.damage = damage;
		this.panel = panel;
	}
	@Override
	public void run() {
		JLabel label = new JLabel(String.valueOf(damage));
		label.setFont(new Font("Vijaya", Font.BOLD, 32));
		label.setForeground(new Color(255, 0, 0));
		label.setHorizontalAlignment(SwingConstants.CENTER);
		label.setBounds(obj.getBounds());
		
		panel.add(label);
		panel.setLayer(label, 60);
		panel.repaint();
		
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		panel.remove(label);
		panel.repaint();
	}

}
